<?php

require_once('dbconnect.inc.php');
require_once('auth.inc.php');

$auth = new auth();
$auth->setDefRedir('index.php');
$user = $auth->isauth($dbh,$_COOKIE);

try
{
    $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $dbh->beginTransaction();

    $sth = $dbh->prepare('insert into log (log_date,log_type, imp, user,log_msg) values (NOW(),0,0,:user,"Оператор вышел из системы")');
    $sth->execute(array('user'=> $user['login']));

    $dbh->commit();
}
catch (Exception $e)
{
    $dbh->rollBack();
}

header($auth->getAuthRedir());  
$cookie = $auth->getCookie();
setcookie($cookie['name'], '');

?>